package com.oauth.google.server.youtube.util;

import java.util.ArrayList;
import java.util.List;

import com.google.gdata.data.youtube.VideoEntry;
import com.oauth.google.client.beans.youtube.YouTubeVideo;

public class GoogleYoutubeUtil {

	public static List<YouTubeVideo> convertToVideos(List<VideoEntry> videoList) {
		List<YouTubeVideo> videos = new ArrayList<YouTubeVideo>();
		for (VideoEntry entry : videoList) {
			videos.add(convertToEntry(entry));
		}
		return videos;
	}

	public static YouTubeVideo convertToEntry(VideoEntry pEntry) {
		YouTubeVideo video = new YouTubeVideo();
		video.setTitle(pEntry.getTitle().getPlainText());
		if (pEntry.getHtmlLink() != null) {
			video.setLink(pEntry.getHtmlLink().getHref());
		}
		return video;
	}

}
